/*****************************************************
Copyright (C) 2020. All rights reserved.
File name     ：TestMain.c
Version       ：v1.0
Author        ：zhengqijun
Date          ：2020-04-10
Function List ：
Description   ：main function
******************************************************/

#include <stdio.h>  // for printf
#include "DisjointSet.h"

// main function
int main(void) {
    DisjSet S;
    SetType Root1;
    SetType Root2;
    int i;
    int j;
    int k;

    Initialize(S);

    k = 1;
    while (k <= 8) {
        j = 1;
        while(j < NumSets) {
            Root1 = Find(j, S);
            Root2 = Find(j + k, S);
            SetUnion(S, Root1, Root2);
            j += 2 * k;
        }

        k *= 2;
    }

    k = 0;
    for (i = 1; i <= NumSets; ++i) {
        Root1 = Find(i, S);
        printf("[%03d:%03d]\t", i, Root1);
        ++k;
        if (k == 5) {
            k = 0;
            printf("\n");
        }
    }

    return 0;
}

// EOF

